package com.wunong.smart.commission.domain.business.impl;

import com.wunong.smart.commission.application.context.CommissionContext;
import com.wunong.smart.commission.application.request.support.CommissionEntryRequest;
import com.wunong.smart.commission.application.request.support.CreateCommissionRequest;
import com.wunong.smart.commission.domain.business.CreateCommissionBusinessExt;
import com.wunong.smart.domain.platform.common.BizSource;
import com.wunong.smart.domain.platform.common.VerifyDTO;

import java.util.Objects;

/**
 * @author create by zealot.zt
 */
public class DefaultCreateCommissionBusinessExt implements CreateCommissionBusinessExt {

    @Override
    public String getUniqueKey(CreateCommissionRequest request) {
        BizSource source = request.getSource();
        return source.getBizId() + "_" + source.getBizType()
                + "_" + request.getCommissionType();
    }

    @Override
    public VerifyDTO canCreate(CommissionContext<CommissionEntryRequest> context) {
        CommissionEntryRequest request = context.getRequest();
        if (Objects.isNull(request.getCommissionType())) {
            return VerifyDTO.unavailable("亲，未知的代办类型");
        }

        return VerifyDTO.available();
    }

}
